package parser.absyn;
import utils.Constant;

public class DataType {
	public int type;
	public int para1;//for char, varchar, dec
	public int para2;//for dec
	public DataType(String s, int p1, int p2){
		type = typefromString(s);
		para1 = p1;
		para2 = p2;
	}
	
	private int typefromString(String s){
		if(s.equalsIgnoreCase("int"))
			return Constant.INT;
		else if (s.equalsIgnoreCase("float"))
			return Constant.FLOAT;
		else if (s.equalsIgnoreCase("char")||s.equalsIgnoreCase("varchar"))
			return Constant.STRING;
		else if (s.equalsIgnoreCase("datetime"))
			return Constant.DATE;
		else if (s.equalsIgnoreCase("boolean"))
			return Constant.BOOL;
		else if (s.equalsIgnoreCase("decimal"))
			return Constant.DECIMAL;
		else if (s.equalsIgnoreCase("timestamp"))
			return Constant.TIMESTAMP;
		else {
			throw new Error("undefined type");
		}
	}
}
